<?php
require_once 'Zend/View/Helper/Abstract.php';

/**
 * Helper to access user information in a view. Internally uses {@link Translator_User}
 * but hides all methods behind a proxy to prevent access to internal methods which
 * should not be used in a view helper.
 */
class Zend_View_Helper_User extends Zend_View_Helper_Abstract
{
	/**
	 * @var Translator_User
	 */
	private $_user;
	
	/**
	 * 
	 * Enter description here ...
	 */
	public function __construct() {
		$this->_user = Zend_Registry::get('user');
	}
	
	/**
	 * Helper entry method, just returns this object. 
	 * 
	 * @return Zend_View_Helper_User
	 */
	public function user() {
		return $this;
	}
	
	/**
	 * @return bool Whether user is logged in
	 */
	public function isAuthenticated() {
		return $this->_user->isAuthenticated();
	}
	
	/**
	 * @return bool Whether user is an administrator
	 */
	public function isAdministrator() {
		return $this->_user->isAdministrator();
	}
	
	/**
	 * @return bool Whether user is translator
	 * @param $pending
	 */
	public function isTranslator($pending = false) {
		return $this->_user->isTranslator($pending);
	}
	
	/**
	 * @param string $field
	 */
	public function __get($field) {
		return $this->_user->$field;
	}
	
	/**
	 * @param string $field
	 */
	public function __isset($field) {
		return isset($this->_user->$field);
	}
}